package org.onion.pattern.kit.springtool.converter;

import org.springframework.core.convert.converter.Converter;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class Long2LocalDateTimeConvert implements Converter<Long, LocalDateTime> {

    @Override
    public LocalDateTime convert(Long s) {
        if (s <= 0) {
            return LocalDateTime.MIN;
        }

        return LocalDateTime.ofInstant(Instant.ofEpochMilli(s), ZoneId.systemDefault());
    }

}
